package com.wmeimob.fastboot.jiubei.controller;

import com.wmeimob.fastboot.jiubei.entity.ShopGoodsClassify;
import com.wmeimob.fastboot.jiubei.service.ShopGoodsClassifyService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author wjt
 * @version 1.0
 * @className ShopGoodsClassifyController
 * @description 【商城商品分类】控制器
 * @date Wed Aug 26 21:50:57 CST 2020
 **/
@RestController
@RequestMapping("shopGoodsClassify")
@Slf4j
public class ShopGoodsClassifyController {

    @Resource
    private ShopGoodsClassifyService shopGoodsClassifyService;


    /**
     * 商城商品分类分页查询
     *
     * @param shopGoodsClassify
     * @return
     */
    @GetMapping
    public List<ShopGoodsClassify> queryForShopGoodsClassify(ShopGoodsClassify shopGoodsClassify) {
        shopGoodsClassify.setDel(false);
        return shopGoodsClassifyService.findAll(shopGoodsClassify);
    }

    /**
     * 查询一级类目
     */
    @GetMapping("/queryByFirst")
    public List<ShopGoodsClassify> selectListByPidFirst() {
        return shopGoodsClassifyService.selectListByPidFirst();
    }

    /**
     * 根据上级分类id查询下级分类列表
     *
     * @param id
     * @return
     */
    @GetMapping("/second/{id}")
    public List<ShopGoodsClassify> selectListByPid(@PathVariable("id") Integer id) {
        ShopGoodsClassify goodsClassify = new ShopGoodsClassify();
        goodsClassify.setId(id);
        return shopGoodsClassifyService.selectListByPid(goodsClassify);
    }

    /**
     * 商城商品分类查询-<通过id查询>
     *
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public ShopGoodsClassify queryForShopGoodsClassifyById(@PathVariable("id") Object id) {
        return shopGoodsClassifyService.queryShopGoodsClassifyById(id);
    }
}
